{extend name="base" /} {block name="body"}
<div class="admin-main">
    <div class="layui-field-box layui-form">
        <a href="{:url('feelym/forumcate/add')}" class="layui-btn layui-btn-sm" id="add">
            <i class="layui-icon">&#xe608;</i> 添加板块
        </a>
        <a href="javascript:;" data-id='0' data-uids="{$superbanzhu}" class="layui-btn layui-btn-sm banzhu">
            <i class="layui-icon">&#xe608;</i> 设置超级版主
        </a>
        <table class="layui-table admin-table">
            <thead>
                <tr>
                    <th width="5%" align="center">ID</th>
                    <th align="center">板块名称</th>
                    <th width="10%" align="center">是否显示</th>
                    <th width="10%" align="center">板块图片</th>
                    <th width="20%" align="center">板块连接</th>
                    <th width="20%" align="center">模板</th>
                    <th width="10%" align="center">版主</th>
                    <th width="200" align="center">基本操作</th>
                </tr>
            </thead>
            <tbody>
                {volist name="category_level_list" id="vo"}
                <tr>
                    <td align="center">{$vo.id}</td>
                    <td style="padding-left: 20px;"><a target="_blank" href="{:url('bbs/index/view',array('cate_alias'=>$vo.alias))}">{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' --';}{/php}{/neq} {$vo.name}</a></td>
                    <td align="center">

                        <input type="checkbox" name="show" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchshow" value="{$vo['id']}" {php}echo $vo[ 'show']==1 ? 'checked' : '';{/php}>
                    </td>

                    <td align="center">{if condition="$vo['pic'] neq ''"}<img style="border: 1px solid #CDCDCD;padding: 3px;border-radius: 2px;" src="__ROOT__{$vo.pic}" height="25">{else /}暂无图片{/if}</td>
                    <td style="padding-left: 20px;">{:url('bbs/index/view',array('cate_alias'=>$vo.alias))}</td>
                    <td align="center">{$vo.template}</td>
                    <td align="center">{$vo.bauzhu}</td>
                    <td align="left">
                        <a class="layui-btn layui-btn-normal layui-btn-sm" href="{:url('forumcate/edit',array('id'=>$vo['id']))}">修改</a>
                        <a href="javascript:;" data-id="{$vo.id}" data-url="{:url('feelym/forumcate/delete',array('id'=>$vo['id']))}" data-opt="del" class="elementdel layui-btn layui-btn-danger layui-btn-sm ajax-delete">删除</a> {if $vo.tid eq 0}<a class="layui-btn layui-btn-sm banzhu"
                            href="javascript:;" data-id="{$vo.id}" data-uids="{$vo.uids}">设置版主</a>{/if}
                    </td>
                </tr>
                {/volist}
            </tbody>
        </table>
    </div>
</div>
{/block} {block name="js"}
<script type="text/javascript" src="__ADMIN__/js/delelement.js"></script>
{/block} {block name="script"}
<script>
    layui.use(['form'], function() {
        var form = layui.form,
            jq = layui.jquery;
        var status = 0;
        form.on('switch(switchTest)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('feelym/forumcate/updatestatus')}?id=" + data.value + '&status=' + status + '&name=sidebar';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
        var status = 0;
        form.on('switch(switchshow)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            if (data.elem.checked) {
                status = 1;
            } else {
                status = 0;
            }
            var url = "{:url('feelym/forumcate/updatestatus')}?id=" + data.value + '&status=' + status + '&name=show';


            jq.get(url, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        //  location.reload();
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });

        jq('.banzhu').on('click', function() {
            var cid = jq(this).data('id');
            var olduids = jq(this).data('uids');
            var url = "{:url('forumcate/setbanzhu')}";
            layer.prompt({
                title: '请输入用户ID,多个请用英文逗号分隔',
                value: olduids
            }, function(uids, index) {

                jq.post(url, {
                    cid: cid,
                    uids: uids
                }, function(data) {

                    if (data.code == 200) {

                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            location.reload();
                        });
                    } else {

                        layer.msg(data.msg, {
                            icon: 2,
                            anim: 6,
                            time: 1000
                        });
                    }
                    layer.close(index);

                });
            });
        })
    })
</script>
{/block}